package com.eastfair.certificate.enumeration;

import com.eastfair.annotation.base.BaseEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.stream.Stream;

/**
 * 证件基础角色枚举.
 *
 * @author ligang
 * @date 2022 /7/28
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum CertificateRoleEnum implements BaseEnum {
    /**
     * 配套服务商.
     */
    ORDINARY_ROLE("证件基础角色"),
    /**
     * 其他角色.
     */
    ROLE_OTHER("其他角色"),

    ;

    @ApiModelProperty(value = "描述")
    private String desc;

    public static CertificateRoleEnum match(String val, CertificateRoleEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static CertificateRoleEnum get(String val) {
        return match(val, null);
    }

    @Override
    public String getCode() {
        return this.name();
    }

    public boolean eq(CertificateRoleEnum val) {
        return val != null && eq(val.name());
    }
}